package cn.xi.dao;

import cn.xi.pojo.Role;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface RoleDao {


    @Select("select r.* from t_role r,t_user_role ur where  r.id=role_id and ur.user_id=#{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "keyword", column = "keyword"),
            @Result(property = "permissions", column = "id", javaType = Set.class, many = @Many(select = "cn.xi.dao.PermissionDao.findPermissions"))
    })
    Set<Role> findRoles(Integer id);
}
